package com.itmate.dao;

import com.itmate.db.DBUtil;
import com.itmate.entity.Admins;


public class AdminDao extends BaseDao{
	
	
	/**
	 * 判断账号密码是否正确
	 * @param u
	 * @return	true 正确，false 不正确
	 */
	
	public boolean login(Admins u) {
		boolean flag = false;
		try {
			int count = 0;
			connection = DBUtil.getConnection();
			String sql = "select count(*) as count from admins where Admin_id = ? and Admin_password = ?";
			preparedStatement = connection.prepareStatement(sql);
			preparedStatement.setInt(1, u.getAdmin_id());
			preparedStatement.setString(2, u.getAdmin_password());
			resultSet = preparedStatement.executeQuery();
			while(resultSet.next()) {
				count = resultSet.getInt("count");
			}
			if(count != 0) {
				flag = true;
			}
		}catch (Exception e) {
			e.printStackTrace();
		}finally {
			closed();
		}
		return flag;
	}
	
	
	
	
	
	
	
	
	

}
